<script setup lang="ts">
import dayjs from 'dayjs';
import { ref } from 'vue';
import AuthBar from '@/components/authBar/index.vue';
import { dictVal2Text } from '@/utils/dict.utils';
import { withQueryString } from '@/utils/router.utils';

const sortList = ref([
  {
    label: '默认',
    value: 1
  },
  {
    label: '医生数量',
    value: 2
  }
]);

const sortType = ref(1);

const doctorList = ref([
  {
    id: '1',
    name: '张伟',
    department: '内科',
    title: '主任医师',
    specialty: '心血管疾病',
    schedule: '周一上午',
    avatar: 'http://192.168.1.3:9010/hnxyc/3bb0616ee8e2f13c27dbb7b3ffd7b40510454b04c494ffac733693e1526b8294.png'
  },
  {
    id: '2',
    name: '李强',
    department: '外科',
    title: '副主任医师',
    specialty: '呼吸系统疾病',
    schedule: '周二下午',
    avatar: 'http://192.168.1.3:9010/hnxyc/3bb0616ee8e2f13c27dbb7b3ffd7b40510454b04c494ffac733693e1526b8294.png'
  },
  {
    id: '3',
    name: '王芳',
    department: '儿科',
    title: '主治医师',
    specialty: '儿科常见病',
    schedule: '周三全天',
    avatar: 'http://192.168.1.3:9010/hnxyc/3bb0616ee8e2f13c27dbb7b3ffd7b40510454b04c494ffac733693e1526b8294.png'
  },
  {
    id: '4',
    name: '赵敏',
    department: '妇产科',
    title: '主任医师',
    specialty: '消化系统疾病',
    schedule: '周四上午',
    avatar: 'http://192.168.1.3:9010/hnxyc/3bb0616ee8e2f13c27dbb7b3ffd7b40510454b04c494ffac733693e1526b8294.png'
  },
  {
    id: '5',
    name: '刘洋',
    department: '骨科',
    title: '主治医师',
    specialty: '骨折治疗',
    schedule: '周五下午',
    avatar: 'http://192.168.1.3:9010/hnxyc/3bb0616ee8e2f13c27dbb7b3ffd7b40510454b04c494ffac733693e1526b8294.png'
  },
  {
    id: '6',
    name: '陈磊',
    department: '神经科',
    title: '副主任医师',
    specialty: '神经系统疾病',
    schedule: '周六上午',
    avatar: 'http://192.168.1.3:9010/hnxyc/3bb0616ee8e2f13c27dbb7b3ffd7b40510454b04c494ffac733693e1526b8294.png'
  },
  {
    id: '7',
    name: '孙丽',
    department: '内科',
    title: '主任医师',
    specialty: '呼吸系统疾病',
    schedule: '周二下午',
    avatar: 'http://192.168.1.3:9010/hnxyc/3bb0616ee8e2f13c27dbb7b3ffd7b40510454b04c494ffac733693e1526b8294.png'
  },
  {
    id: '8',
    name: '周杰',
    department: '外科',
    title: '住院医师',
    specialty: '消化系统疾病',
    schedule: '周四上午',
    avatar: 'http://192.168.1.3:9010/hnxyc/3bb0616ee8e2f13c27dbb7b3ffd7b40510454b04c494ffac733693e1526b8294.png'
  },
  {
    id: '9',
    name: '黄蓉',
    department: '儿科',
    title: '主任医师',
    specialty: '儿科常见病',
    schedule: '周三全天',
    avatar: 'http://192.168.1.3:9010/hnxyc/3bb0616ee8e2f13c27dbb7b3ffd7b40510454b04c494ffac733693e1526b8294.png'
  },
  {
    id: '10',
    name: '吴刚',
    department: '心血管科',
    title: '副主任医师',
    specialty: '心血管疾病',
    schedule: '周一上午',
    avatar: 'http://192.168.1.3:9010/hnxyc/3bb0616ee8e2f13c27dbb7b3ffd7b40510454b04c494ffac733693e1526b8294.png'
  }
]);

function handleClick(item) {
  uni.navigateTo({
    url: withQueryString('/pages/informationQuery/doctorDetail', {
      id: item.id
    })
  });
}
</script>

<template>
  <view class="page flex-col">
    <AuthBar />
    <view class="flex-1 overflow-auto pb-40">
      <view class="page-content mx-48 mt-32">
        <view class="page-title flex items-center justify-between">
          医生信息查询结果
          <view class="search-time">
            查询时间：{{ dayjs().format("YYYY/MM/DD HH:mm:ss") }}
          </view>
        </view>
        <view class="page-subtitle flex items-center justify-between">
          共找到4条结果
          <view class="search-sort flex items-center">
            排序：
            <view class="relative w-166">
              <wd-picker v-model="sortType" :columns="sortList" title="选择排序类型" use-default-slot>
                <wd-input :placeholder="dictVal2Text(sortType, sortList)" readonly />
              </wd-picker>

              <view class="select-arrow">
                <wd-icon name="arrow-down" size="22px" color="var(--primary)" />
              </view>
            </view>
          </view>
        </view>
        <view class="search-group">
          <view v-for="item in doctorList" :key="item.title" class="search-item flex items-center justify-between" @click="handleClick(item)">
            <view>
              <view class="search-item__name">
                {{ item.name }}
              </view>
              <view class="search-item__info">
                {{ item.title }} · {{ item.department }}
              </view>
              <view class="search-item__desc">
                专长：{{ item.specialty }}  |  出诊时间：{{ item.schedule }}
              </view>
              <view class="search-item__detail">
                查看详情 <wd-icon name="arrow-right" size="32px" />
              </view>
            </view>

            <view class="search-item__cover">
              <image :src="item.avatar" mode="aspectFill" class="h-full w-full" />
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<route type="page" lang="json5">
{
  layout: 'default',
  style: {
    navigationBarTitleText: '医生信息',
    navigationStyle: 'custom'
  }
}
</route>

<style lang="scss" scoped>
.page {
  height: 100%;
  background-color: var(--bg-color);

  .page-content {
    border: 2px solid #e6effd;
    background: #d8e7ff;
    border-radius: 20px;
    padding: 40px 52px;
  }

  .page-title {
    font-size: 48px;
    font-weight: bold;
    color: var(--text-color);

    .search-time {
      font-size: 28px;
      color: #686869;
      font-weight: normal;
    }
  }

  .page-subtitle {
    font-size: 30px;
    color: var(--secondary-text-color);

    .search-sort {
      position: relative;
      --wot-input-inner-height: 60px;
      --wot-input-fs: 24px;
      --wot-input-placeholder-color: #767676;

      :deep(.wd-input) {
        border-radius: 8px;
        background: #eff5ff;
        border: 1px solid #ffffff;
        box-sizing: border-box;
        padding-left: 20px;

        &:after {
          background: transparent;
        }
      }

      .select-arrow {
        position: absolute;
        right: 24px;
        top: 50%;
        transform: translateY(-50%);
      }
    }
  }

  .search-group {
    margin-top: 36px;

    .search-item {
      background: #f5f9ff;
      padding: 43px 40px;
      border-radius: 20px;
      margin-bottom: 20px;

      .search-item__name {
        font-size: 48px;
        font-weight: bold;
        color: var(--text-color);
      }

      .search-item__info {
        font-weight: 400;
        font-size: 24px;
        color: var(--secondary-text-color);
      }

      .search-item__desc {
        font-size: 26px;
        color: #686869;
        margin-top: 20px;
      }

      .search-item__detail {
        color: var(--primary);
        font-size: 32px;
        margin-top: 24px;
      }

      .search-item__cover {
        border-radius: 20px;
        overflow: hidden;
        width: 207px;
        height: 225px;
      }

      &:hover,
      &:active {
        background-color: var(--primary);

        .search-item__name,
        .search-item__info,
        .search-item__desc,
        .search-item__detail {
          color: #fff;
        }
      }
    }
  }
}
</style>
